public class test {

    public static void main(String[] args){
        int cap,bottle,sum;//cap瓶盖个数，bottle 空瓶个数，sum统计总共换的；
        cap = bottle = 10000/2; //未兑换前个数
        sum=0;
        int i=0;
        while(cap > 4 || bottle > 1) {
            sum =  cap / 4;	//用盖子兑换
            sum += bottle / 2;	//用空瓶子兑换
            cap=sum+cap%4;
            bottle=sum+bottle%2;
            i+=sum;
        }
        System.out.println(i+5000);
    }
}
